/*
 * @Author: youngqj youngqj@126.com
 * @Date: 2024-11-02 18:07:42
 * @LastEditors: youngqj youngqj@126.com
 * @LastEditTime: 2024-12-03 18:18:52
 * @Description:
 *
 * Copyright © Zhejiang Xiaoqu Information Technology Co., Ltd, All Rights Reserved.
 */
package dto

import (
	"fmt"
	"time"

	"xiaoquio/web/core/utils"
	modle "xiaoquio/web/model"
)

type MemberDTO struct {
	ID       string `json:"id"` // 加密后的ID
	Username string `json:"username"`
	Nikname  string `json:"nikname"`
	Avatar   string `json:"avatar"`
	CreateAt string `json:"create_at"`
	IsValid  bool   `json:"is_valid"`
	InfoURL  string `json:"url"`
}

func GetMemberDTO(member modle.MemberModel) MemberDTO {
	userID := fmt.Sprintf("%v", member.ID)
	encodingUserID, _ := utils.Encrypt(userID)
	createTime := time.Unix(member.CreateAt, 0).Format("2006-01-02 15:04:05")
	url := "member/info/" + encodingUserID

	return MemberDTO{
		ID:       encodingUserID, // 使用你的加密函数
		Username: member.Username,
		Nikname:  member.Nikname,
		Avatar:   member.Avatar,
		CreateAt: createTime,
		IsValid:  member.IsValid,
		InfoURL:  url,
	}
}
